﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using music.Facades;
using music.Models;

namespace MusicStore.Controllers
{
    public class StoreController : Controller
    {
        //
        // GET: /Store/

        public ActionResult Index()
        {
            GenreViewModel model = MusicFacade.GetGenreViewModel();
            return View(model);
        }
        public ActionResult BrowseAlbum(string genre)
        {
            AlbumViewModel model = MusicFacade.GetAlbumViewModel(genre);
            return View(model);
        }
        public ActionResult EditAlbum(int albumId)
        {
            var model = MusicFacade.GetAlbumById(albumId);

            return View(model);
        }
        [HttpPost]
        public ActionResult EditAlbum(int albumId, FormCollection formValues)
        {
            var model = MusicFacade.GetAlbumById(albumId);
            UpdateModel(model);
            MusicFacade.UpdateAlbum(model);
            return RedirectToAction("Index");
        }
    }
}
